/*
 * Copyright (c) 2010 - 2011, Brookhaven National Laboratory
 * All rights reserved.
 * The software in this package is published under the terms
 * of the BSD license a copy of which has been included with
 * this distribution in the license.txt file.
 */

package org.oxtypes.impl;

import java.math.BigDecimal;

import org.omg.dds.type.dynamic.DynamicType;

import org.oxtypes.DynamicData;

/**
 *
 */
public class PrimitiveImpl {

    /** Wrapper of the double value */
    public static class DoubleData extends AbstractDynamicData {

        double value;

        public DoubleData(){}

        public DoubleData(double value){
            this.value = value;
        }

        public DynamicType getType(){
            return  DynamicTypeManagerImpl.float64Type;
        }

        public int getLength(){
            return 1;
        }

        public DynamicData setInt16Value(int id, short value){
            this.value = value;
            return this;
        }

        public DynamicData setInt32Value(int id, int value){
            this.value = value;
            return this;
        }

        public DynamicData setFloat32Value(int id, float value){
            this.value = value;
            return this;
        }

        public DynamicData setFloat64Value(int id, double value){
            this.value = value;
            return this;
        }

        public double getFloat64Value(int id){
            return this.value;
        }

        public BigDecimal getBigDecimalValue(int id){
            return new BigDecimal(this.value);
        }
    }

}
